using System;
using System.ComponentModel.DataAnnotations.Schema;

namespace UwinEducation.Domain.Entities
{
    /// <summary>
    /// 教师假期实体
    /// </summary>
    [Table("teacher_vacations")]
    public class TeacherVacation : EntityBase
    {
        /// <summary>
        /// 假期ID
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        /// 教师ID
        /// </summary>
        public Guid TeacherId { get; set; }

        /// <summary>
        /// 开始时间
        /// </summary>
        public DateTime StartTime { get; set; }

        /// <summary>
        /// 结束时间
        /// </summary>
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 请假原因
        /// </summary>
        public string Reason { get; set; }

        /// <summary>
        /// 关联的教师
        /// </summary>
        public virtual Teacher Teacher { get; set; }

        /// <summary>
        /// 创建教师假期
        /// </summary>
        public static TeacherVacation Create(
            Guid teacherId,
            DateTime startTime,
            DateTime endTime,
            string reason)
        {
            if (startTime > endTime)
            {
                throw new ArgumentException("开始时间必须早于结束时间");
            }

            return new TeacherVacation
            {
                Id = Guid.NewGuid(),
                TeacherId = teacherId,
                StartTime = startTime,
                EndTime = endTime,
                Reason = reason,
                CreatedAt = DateTime.Now
            };
        }
    }
}